package org.example.consumer;

import org.example.consumer.model.Student;

import java.util.function.Consumer;
import java.util.function.Predicate;

public class PredicateConsumerDemo {
    public static Student updateStudentFee(Student student, Predicate<Student> predicate, Consumer<Student> consumer){
        if (predicate.test(student)){
            consumer.accept(student);
        }
        return student;
    }

    public static void main(String[] args) {
        Student student1 = new Student("Ashok","Kumar", 9.5);

        student1 = updateStudentFee(student1,
                //Lambda expression for Predicate interface
                student -> student.getGrade() > 8.5,
                //Lambda expression for Consumer inerface
                student -> student.setFeeDiscount(30.0) );
        student1.printFee(); //The fee after discount: 1400.0

    }
}
